//
//  SimilarViewCell.m
//  Coco_Music
//
//  Created by dlios on 15-6-27.
//  Copyright (c) 2015年 寇广超. All rights reserved.
//

#import "SimilarViewCell.h"

@implementation SimilarViewCell
-(void)dealloc
{
    [_NameLabel release];
    [_songsCountLabel release];
    [_albumsCountLabel release];
    [_SingerIV release];
    [_SimilarSinger release];
    [super dealloc];
    
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews
{
    self.SingerIV =[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 70, 70)];
    self.SingerIV.layer.masksToBounds = YES;
    self.SingerIV.layer.cornerRadius  =35;
    [self.contentView addSubview:self.SingerIV];
    [_SingerIV release];
    
    self.NameLabel =[[UILabel alloc]initWithFrame:CGRectMake(self.SingerIV.frame.origin.x+self.SingerIV.frame.size.width+80, self.SingerIV.frame.origin.y, 200, 30)];
    [self.contentView addSubview:self.NameLabel];
    [_NameLabel release];
    
    self.songsCountLabel =[[UILabel alloc]initWithFrame:CGRectMake(self.SingerIV.frame.origin.x+self.SingerIV.frame.size.width+60, self.NameLabel.frame.origin.y+self.NameLabel.frame.size.height, 80, 30)];
    self.songsCountLabel.font =[UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.songsCountLabel];
    [_songsCountLabel release];
    
    self.albumsCountLabel =[[UILabel alloc]initWithFrame:CGRectMake(self.songsCountLabel.frame.origin.x +self.songsCountLabel.frame.size.width, self.songsCountLabel.frame.origin.y, 80, 30)];
    self.albumsCountLabel.font =[UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.albumsCountLabel];
    [_albumsCountLabel release];
    
    UIImageView *ImageV =[[UIImageView alloc]initWithFrame:CGRectMake(self.SingerIV.frame.origin.x+20, self.SingerIV.frame.size.height+self.SingerIV.frame.origin.y+5, [UIScreen mainScreen].bounds.size.width-self.SingerIV.frame.origin.x*2-40 ,2)];
    ImageV.backgroundColor =[UIColor lightGrayColor];
    [self addSubview:ImageV];
    [ImageV release];
    
    
}
-(void)setSimilarSinger:(similarSinger *)SimilarSinger
{
    if (_SimilarSinger != SimilarSinger) {
        [_SimilarSinger release];
        _SimilarSinger = [SimilarSinger retain];
        
    }
   self.NameLabel.text = [NSString stringWithFormat:@"%@",SimilarSinger.chineseName];
   self.songsCountLabel.text =[NSString stringWithFormat:@"%ld首单曲",(long)SimilarSinger.songsCount];
    self.albumsCountLabel.text =[NSString stringWithFormat:@"%ld张专辑",(long)SimilarSinger.albumsCount];
    
#pragma  crash !!!!没解决

    NSURL *url =[NSURL URLWithString:SimilarSinger.picUrl];
    
    if ([url isEqual:[NSNull null]])
    {
        
    }
    else
    {
    [self.SingerIV sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"cm2_default_artist_banner-1"]];
    }
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
